home *** CD-ROM | disk | FTP | other *** search
-
- #include "../CGVPMacro.csi"
-
-
- VertAttributes { POSITION_3 TEXCOORD0_2 PRIM_COLOR TANG_3X3 }
- MainInput { VIEWPROJ_MATRIX, uniform float3x4 ObjToCubeSpace, uniform float3 CameraPos, uniform float4 Constants }
- DeclarationsScript
- {
- IN_T0_C0_TANG
- OUT_T0_T1_T2_T3_C0
- }
- PositionScript = PosCommon
- CoreScript
- {
- // pass texture coordinates for fetching the normal map
- OUT.Tex0 = IN.TexCoord0;
-
- float3 eyeVector = CameraPos.xyz - vPos.xyz;
-
- TANG_MATR
-
- float3 trEyeVector = mul(objToTangentSpace, eyeVector);
-
- // fTemp = sqrt(n^2*|EYE|^2 - (EYE.x^2 + EYE.y^2)) - EYE.z
- float3 eye2D = trEyeVector;
- eye2D.z = 0;
- float fTemp = sqrt(Constants.y*Constants.y*dot(trEyeVector, trEyeVector) - dot(eye2D, eye2D)) - trEyeVector.z;
-
- // Set the refraction matrix
- // | REFRACT_0 | | -TEMP.w 0 EYE.x*TEMP.w |
- // | REFRACT_1 | = | 0 -TEMP.w EYE.y*TEMP.w |
- // | REFRACT_2 | | -EYE.x -EYE.y -EYE.z |
- float3x3 refrMatr;
- refrMatr[0] = float3(-fTemp, 0, fTemp * trEyeVector.x);
- refrMatr[1] = float3(0, -fTemp, fTemp * trEyeVector.y);
- refrMatr[2] = -trEyeVector;
-
- refrMatr[0] = refrMatr[0] * Constants.x;
- refrMatr[1] = refrMatr[1] * Constants.x;
-
- // Calculate the 3x3 matrix for the pixel shader texm3x3tex
- float3 vTemp0 = mul(objToTangentSpace, ObjToCubeSpace[0].xyz);
- float3 vTemp1 = mul(objToTangentSpace, ObjToCubeSpace[1].xyz);
- float3 vTemp2 = mul(objToTangentSpace, ObjToCubeSpace[2].xyz);
-
- OUT.Tex1.xyz = mul(refrMatr, vTemp0);
- OUT.Tex2.xyz = mul(refrMatr, vTemp1);
- OUT.Tex3.xyz = mul(refrMatr, vTemp2);
-
- OUT.Color = IN.Color;
- }
-